{% extends "dissemin/details.html" %}

{% load staticfiles %}
{% load bootstrap_pagination %}
{% load statuses %}
{% load i18n %}
{% load widget_tweaks %}
{% load choice_tags %}
{% load capture_tags %}

{% block headTitle %}
{{ search_description }}
{% endblock %}

{% block bodyTitle %}
{{ search_description }}
{% endblock %}

{% block jsScript %}
$(function(){
    $('.logoHelpPopover').popover({
        trigger:"hover",
        placement: function(){
            return $(window).width() < 768 ? 'bottom' : 'left'
        }
    });
});
{% endblock %}

{% block details %}

{% if not journal %}
<div class="detailsTitle">
    {% trans "Search" %}
</div>
<div class="detailsContent">
<p>
{% blocktrans trimmed count counter=nb_results %}
    {{ counter }} publisher found
    {% plural %}
    {{ counter }} publishers found
{% endblocktrans %}
</p>

    <form method="get" action="{% url 'publishers' %}" id="searchPublishers">
        <div class="form-group" id="searchPublishersName"><div class="input-group">
            {{ form.q.errors }}
            {% render_field form.q class="form-control" %}
            <label class="input-group-btn">
                <button type="submit" class="btn btn-default">{% trans "Search" %}</button>
            </label>
        </div></div>
        <div class="form-group" id="searchPublishersOAStatus">
            {{ form.oa_status.errors }}
            <label for="{{ form.oa_status.id_for_label }}">{% trans "Filter by publisher policy" %}</label>
            {% for checkbox in form.oa_status %}
            {% with value=checkbox.choice_value %}
            <div class="logoHelpPopover" data-content="{{ value|helptext_oa_status }}">
            <div class="checkbox publisherCriterion">
                {{ checkbox|tag:'onchange="submit()"' }}
                <div class="publisherCriterionBox">
                <label for="{{ checkbox.id_for_label }}">
                    <img alt="" src="{% static value|logo_oa_status %}" height="70px" width="52px" class="pubLogo publisherCriterionLogo">
                    <span class="criterionItem">{{ checkbox.choice_label }}</span>
                </label>
                </div>
            </div>
            </div>
            {% endwith %}
            {% endfor %}
        </div>
        <div class="form-group form-inline" id="searchPublishersSortBy">
            {{ form.reverse_order.errors }}
            {{ form.sort_by.errors }}
            {% capture as sort_by silent %}
            <label for="{{ form.sort_by.id_for_label }}">{% trans "Sort by" %}</label>
            {% endcapture %}
            {% capture as increasing silent %}
            {% render_field form.reverse_order class="form-control" onchange="submit()" %}
            {% endcapture %}
            {% capture as value silent %}
            {% render_field form.sort_by class="form-control" onchange="submit()" %}
            {% endcapture %}
            {% blocktrans trimmed %}
            {{ sort_by }} <div>{{ increasing }} {{ value }}</div>
            {% endblocktrans %}
        </div>
        <noscript>
            <div class="form-group"><button type="submit" class="btn btn-default">{% trans "Search" %}</button></div>
        </noscript>
    </form>
{% endif %}

<p class="sherpaAcknowledgement">{% trans "Data provided by" %}<br />
<a href="http://www.sherpa.ac.uk/romeo/"><img src="{% static "img/sherpa-romeo.gif" %}" width="210px" alt="SHERPA/RoMEO" /></a></p>
</div>
{% endblock %}

{% block lists %}
 {% if paginator.num_pages > 1 %}
 <div class="searchPages">{% bootstrap_paginate page_obj range=10 %}</div>
 {% endif %}
 {% for result in page_obj %}{% with publisher=result.object %}
 {% if forloop.first %}<ul class="withoutTriangles">{% endif %}
    <li>
        <div class="publisher">
           <div class="pubLogo">
               <div class="pubLogoPic-{{ publisher.oa_status }}">
               </div>
           </div>
           <div class="criterionItem">
               <span class="paperTitle">
                   <a href="{{ publisher.canonical_url }}">{{ publisher }}</a>
                       {% if publisher.stats %}
                           <span class="numPapers">
                               {% blocktrans trimmed count num_total=publisher.stats.num_tot %}
                               ({{ num_total }} paper)
                               {% plural %}
                               ({{ num_total }} papers)
                               {% endblocktrans %}
                           </span>
                       {% endif %}
               </span>
           </div>
        </div>
    </li>    
        {% if forloop.last %}</ul>{% endif %}
 {% endwith %}{% empty %}
 <p class="notFound">{% trans "No publisher found." %}</p>
 {% endfor %}
 {% if paginator.num_pages > 1 %}
 <div class="searchPages">{% bootstrap_paginate page_obj range=10 %}</div>
 {% endif %}
{% endblock %}

